<template>
  <div class="file_icon">
    <i v-if="fileToLowerCase(fileName).match(/.(xls|xlsx)$/)" class="iconfont icon-ic_exl"></i>
    <!--<i v-else-if="fileToLowerCase(fileName).match(/.(txt)$/)" class="iconfont icon-ic_txt"></i>-->
    <i v-else-if="fileToLowerCase(fileName).match(/.(doc|docx)$/)" class="iconfont icon-ic_word"></i>
    <i v-else-if="fileToLowerCase(fileName).match(/.(pdf)$/)" class="iconfont icon-ic_pdf"></i>
    <i v-else class="iconfont icon-ic_file"></i>
  </div>
</template>

<script>
export default {
  name: 'FileIcon',
  props: {
    fileName: {
      type: String,
      required: true
    }
  },
  methods: {
    fileToLowerCase(fileName) {
      return fileName.toLowerCase()
    }
  }
}
</script>

<style lang="less" scoped>
  .file_icon {
    display: inline;
    .icon-ic_txt{
      color: #ac8cba;
    }
    .icon-ic_pdf {
      color: #ff5351;
    }
    .icon-ic_word {
      color: #2196f3;
    }
    .icon-ic_exl {
      color: #33cc66;
    }
  }
</style>
